package com.netease.examination.service;

import com.netease.examination.dao.LoginDAO;
import com.netease.examination.util.ExaminationUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * designed by destiny
 *
 * @author destiny
 *         e-mail destinywk@163.com
 *         github https://github.com/DestinyWang
 *         oschina https://git.oschina.net/destinywk
 * @version JDK 1.8.0_101
 * @since 2017/3/30 22:16
 */
@Service
public class LoginService {

    @Resource
    private LoginDAO loginDAO;

    public String findPassword(String userName) {
        return loginDAO.findPassword(userName);
    }

    public String getToken(String userName, String password) {
        String salt = ExaminationUtil.getSalt();
        String timeSpan = ((Long) System.currentTimeMillis()).toString();
        String originalMsg = userName + password + timeSpan + salt;
        String MD5Encrypt = ExaminationUtil.getMD5Code(originalMsg);
        return MD5Encrypt;
    }


}
